﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ctrip.Automation.Framework.Lib;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using System.Diagnostics;
using Newtonsoft.Json;

namespace API.Taolx.Shopping.Business
{
   public class VerifyResponse
    {
        private string _ResponseString = string.Empty;

        public VerifyResponse(string ResponseString)
        {
            _ResponseString = ResponseString;
        }


        /// <summary>
        /// 验证Attribute变量
        /// </summary>
        /// <param name="Value">变量值</param>
        /// <param name="Parameter">变量名</param>
        public void VerifyResultDataByAttributeValue(string Value, string attr)
        {
            //检查点
           // JObject jo = JObject.Parse(_ResponseString);
            JObject jo = (JObject)JsonConvert.DeserializeObject(_ResponseString);
           // string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();
            string IsSuccess = jo[attr].ToString();
            // 验证返回报文Json的节点值
            CtripAssert.AreEqual(Value,IsSuccess);
            Trace.WriteLine(attr);
        }

        /// <summary>
        /// 验证Attribute变量
        /// </summary>
        /// <param name="Value">变量值</param>
        /// <param name="Parameter">变量名</param>
     /**   public void VerifyResultDataByIsSuccessValue(string Value, string Parameter)
        {
            //检查点
            JObject jo = JObject.Parse(_ResponseString);
            string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();
            string IsSuccess = values[0].ToString();

            // 验证返回报文Json的节点值
            CtripAssert.AreEqual(Value, IsSuccess);
            Trace.WriteLine(Parameter);
        }*/
    }
}
